<template>
  <view class="container">
    <!-- 顶部背景和导航 -->
    <view class="bar">
      <image src="/static/image/图层 1.png" class="bg-image"></image>
      <view class="title">
        <view class="back-arrow" @click="goBack"></view>
        <view>消费记录</view>
        <view></view>
      </view>
    </view>
    
    <!-- 内容区域 -->
    <view class="content">
      <!-- 消费记录列表 -->
      <view class="record-list">
        <view class="record-item" v-for="(record, index) in records" :key="index">
          <view class="record-left">
            <view class="shop-name">{{ record.shop }}</view>
            <view class="record-date">{{ record.date }}</view>
          </view>
          <view class="record-right">
            <text class="amount">-{{ record.amount }}元</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

// 消费记录数据
const records = ref([
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.11 11:09',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.11 11:09',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.11 11:09',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.11 11:09',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.10 14:30',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.09 10:15',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.08 16:45',
    amount: '50'
  },
  {
    shop: '大美汽车维修店-洗车',
    date: '2023.3.07 09:20',
    amount: '50'
  }
])

// 返回上一页
const goBack = () => {
  uni.navigateBack({
    delta: 1,
    fail: (err) => {
      console.log('返回失败:', err)
      uni.switchTab({
        url: '/pages/index/index'
      })
    }
  })
}
</script>

<style>
.container {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.bar {
  width: 100%;
  position: relative;
}

.bg-image {
  width: 100%;
  height: 200px;
}

.title {
  padding: 15px;
  width: 100%;
  display: flex;
  box-sizing: border-box;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
  justify-content: space-between;
  align-items: center;
}

.title view:nth-child(2) {
  color: #fff;
  font-size: 18px;
  font-weight: 500;
}

.title view:nth-child(3) {
  width: 24px;
  height: 24px;
}

.back-arrow {
  width: 24px;
  height: 24px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-arrow::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-top: 2px solid #fff;
  border-left: 2px solid #fff;
  transform: rotate(-45deg);
  top: 50%;
  left: 0;
  margin-top: -6px;
  transition: all 0.3s ease;
}

.back-arrow:hover::before {
  border-color: #007AFF;
  transform: rotate(-45deg) scale(1.1);
}

/* 内容区域 */
.content {
  padding: 20px 15px;
  margin-top: -150px;
  position: relative;
  z-index: 10;
}

/* 记录列表 */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-item {
  background-color: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.record-item:active {
  transform: scale(0.98);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
}

/* 左侧信息 */
.record-left {
  flex: 1;
}

.shop-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.record-date {
  font-size: 14px;
  color: #999;
}

/* 右侧金额 */
.record-right {
  text-align: right;
}

.amount {
  font-size: 16px;
  font-weight: 600;
  color: #FF3B30;
}
</style>